# 构建阶段
FROM golang:1.23-alpine AS builder

# 设置国内镜像源和编译参数
ENV GO111MODULE=on \
    GOPROXY=https://goproxy.cn,direct \
    GOOS=linux

WORKDIR /app

COPY . .

RUN go mod tidy
RUN go build -o main .

# 运行阶段
FROM alpine:latest
LABEL authors="Alex"

WORKDIR /app
COPY --from=builder /app/main .
EXPOSE 8080
CMD ["./main"]
